cmake_minimum_required(VERSION 2.8.3)
project(px4_realsense_bridge)

add_definitions(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
    message_generation
    roscpp
    rospy
    dynamic_reconfigure
    tf
    mavros
    mavros_extras
    mavros_msgs
    mavlink
)

add_message_files(
        FILES
        IMUInfo.msg
        Extrinsics.msg
)
generate_messages(
        DEPENDENCIES
        sensor_msgs
        std_msgs
)
find_package(realsense2 2.24.0)
if(NOT realsense2_FOUND)
    message(FATAL_ERROR "\n\n Intel RealSense SDK 2.0 is missing, please install it from https://github.com/IntelRealSense/librealsense/releases\n\n")
endif()

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS roscpp rospy std_msgs mavros_msgs geometry_msgs mav_msgs sensor_msgs message_runtime tf
)


if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif(NOT CMAKE_BUILD_TYPE)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${YAML_CPP_INCLUDE_DIR}
)

set(PX4_REALSENSE_BRIDGE_CPP_FILES
        "src/nodes/px4_realsense_bridge.cpp"
        "src/nodes/px4_realsense_bridge_node.cpp"
)

add_library(px4_realsense_bridge     "${PX4_REALSENSE_BRIDGE_CPP_FILES}")

add_dependencies(px4_realsense_bridge ${${PROJECT_NAME}_EXPORTED_TARGETS} ${PROJECT_NAME}_generate_messages_cpp ${catkin_EXPORTED_TARGETS})

add_executable(px4_realsense_bridge_node src/nodes/px4_realsense_bridge_node.cpp)

add_dependencies(px4_realsense_bridge_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
include_directories(
        include
        ${realsense2_INCLUDE_DIR}
        ${catkin_INCLUDE_DIRS}
)
target_link_libraries(px4_realsense_bridge_node
          px4_realsense_bridge
          ${catkin_LIBRARIES}
          ${YAML_CPP_LIBRARIES}
        )

target_include_directories(${PROJECT_NAME} PRIVATE ${realsense2_INCLUDE_DIR})

target_link_libraries(${PROJECT_NAME}
        ${realsense2_LIBRARY}
        ${catkin_LIBRARIES}
        ${CMAKE_THREAD_LIBS_INIT}
        )

add_executable(t265_rs_node_sdx src/t265/t265_rs_node_sdx.cpp)
add_dependencies(t265_rs_node_sdx ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(t265_rs_node_sdx
        ${realsense2_LIBRARY}
        ${catkin_LIBRARIES}
        ${CMAKE_THREAD_LIBS_INIT}
        )
